package com.apestech.framework.db.queryData;

import com.apestech.formwork.stream.ListStream;
import com.apestech.framework.db.SqlResultSet;
import com.apestech.framework.db.callback.QueryCallBackHandler;
import com.apestech.framework.json.JSONArray;
import com.apestech.framework.stream.ArrayObject;
import com.apestech.framework.util.FileUtil;

/**
 * @author hup
 * @create 2018-08-16-16:00
 */
public class QueryListStream implements QueryCallBackHandler {

    private ListStream list;

    public QueryListStream(String fileName) throws Exception {
        FileUtil.deleteDir(fileName);
        list=new ListStream(fileName);
    }

    @Override
    public void getData(SqlResultSet rs, JSONArray rslist) throws Exception {
        list.write(new ArrayObject(rs));
    }

    public ListStream getList() {
        return list;
    }
}
